﻿function limparTxt(element) {
    if (element.value == element.defaultValue) {
        element.value = '';
        element.style.color = '#000';
    }
}
function defaultValueTxt(element) {
    if (element.value == '') {
        element.value = element.defaultValue;
        element.style.color = '#CCC';
    }
}

(function () {

            ('#default').stepy();

            ('#custom').stepy({
                backLabel: 'Backward',
                block: true,
                errorImage: true,
                nextLabel: 'Forward',
                titleClick: true,
                validate: true
            });

            ('div#step').stepy({
                finish: false
            });

            // <!-- Optionaly -->
            ('#custom').validate({
                errorPlacement: function (error, element) {
                    ('#custom div.stepy-error').append(error);
                },
                rules: {
                    'email': 'email',
                    'bio': 'required',
                    'password': 'required',
                    'day': 'required',
                    'gender': 'required'
                },
                messages: {
                    'email': { email: 'Invalid e-mail!' },
                    'bio': { required: 'Bio field is required!' },
                    'password': { required: 'Password field is requerid!' },
                    'day': { required: 'Day field is requerid!' },
                    'gender': { required: 'Gender field is requerid!' }
                }
            });

            ('#callback').stepy({
                onBack: function (index) {
                    alert('Going to step ' + index + '...');
                },
                onNext: function (index) {
                    var random = Math.floor(Math.random() * 11);

                    if (random <= 5) {
                        alert('Invalid value!');
                        return false;
                    }

                    alert('Going to step ' + index + '...');
                },
                titleClick: true
            });

        });
